import requests
from config import BASE_URL
# 1.获取图片验证码接口
# (1）发送请求

login_img_get_url = BASE_URL + "/api/captchaImage"
response = requests.get(login_img_get_url)

# # （2）接收响应，并查看检查
# print(response.status_code)
# print(response.json())
# print(response.text)
# 第一中方法
# uuid = response.json()["uuid"]
# 另一种获取方法
uuid = response.json().get("uuid")
print(uuid)


# 登录请求
# （1）发送登录请求
login_post_url = BASE_URL + "/api/login"
login_data = {"username": "admin",
              "password": "HM_2023_test",
              "code": "2",
              "uuid": uuid
              }
print(login_data)
resp = requests.post(login_post_url, json=login_data)

# 打印结果查看并检查
print(resp.status_code)
print(resp.json())
